function update() {
    var selected = $("#goodsTable").bootstrapTable('getSelections');
    var selected_length = selected.length;
    if (!selected_length) {
        $MB.n_warning('请勾选需要修改的商品！');
        return;
    }
    if (selected_length > 1) {
        $MB.n_warning('一次只能修改一个商品！');
        return;
    }
    var id = selected[0].id;
    $.post(ctx + "shopping/goods/getGoods", { "id": id }, function(r) {
        if (r.code == 0) {
            var $form = $('#goods-add');
            $form.modal();
            var goods = r.msg;
            var parentId = r.parentId;
            $("#goods-add-modal-title").html('修改商品');
            $form.find("input[name='id']").val(goods.id);
            $form.find("input[name='name']").val(goods.name);
            $form.find("input[name='price']").val(goods.price);
            $form.find("input[name='pic']").val(goods.pic);
            if(goods.pic){
            	var imgArr = goods.pic.split(";");
            	for (var i = imgArr.length-1; i >=0 ; i--) {
            		if(imgArr[i]!=null && imgArr[i]!="")
            			$('#goodsUpload').createExistImg($tgaUpload,i, imgArr[i]);
				}
            }
            
            $form.find("input[name='parentId']").val(parentId);
            if(parentId!=""){
            	var typeidArr = parentId.split(",");
            	for (var i = 0; i < typeidArr.length; i++) {
            		$('#typeTree').jstree('select_node', typeidArr[i], true);
				}
            }
            
            $form.find("textarea[name='info']").val(goods.info);
            $("#goods-add-button").attr("name", "update");
        } else {
            $MB.n_danger(r.msg);
        }
    });
}